/*
 * @Author: yaolunmao
 */
/*
 * @Author: yaolunmao
 * 简单状态管理
 */

import { reactive } from 'vue';
export const store = {
  state: reactive({
    //选中工具栏
    CurrentlySelectedToolBar: {
      Id: '',
      ImgType: '',
      Type: '', //选中的工具栏svg类型
      TypeName: '', //选中的工具栏svg类型名称
      Title: '', //选中的工具栏svg标题
      Color: '', //选中的工具栏svg颜色
      CreateType: '', //选中工具栏的创建方式
      EChartsOption: '', //选中工具栏的图表默认option
      Template: '',
      Default_Attr: {},
    },
    //地图组件选中栏
    currentSelectMapToolBar: {
      id:'',
      createType: '', //创建类型
      geometryType: '', //地图组件类型
      componentType: '', //组件类型
      name: '', //名称
      layerStyle: {}, //样式
      sourceData: {}, //数据
    },
    //选中背景图片
    BGIMG: {
      ID: 'FirstOneBgImg', //默认
      TYPE: 'default',
      BASE64DATA: '',
    },
    //配置属性面板状态
    configPanalStatus: {
      left: true,
      right: true,
    },
    //当前屏幕宽高
    windowAttributes: {
      width: '',
      height: '',
      absoluteWidth: 0,
      absoluteHeight: 0,
    },
  }),
  setconfigPanalStatusVal(newValue, type = 'left') {
    this.state.configPanalStatus[type] = newValue;
  },
  setCurrentWindowAttributes(newValue) {
    this.state.windowAttributes = newValue;
  },
  setCurrentlySelectedToolBarAction(newValue) {
    this.state.CurrentlySelectedToolBar = newValue;
  },
  setCurrentSelectMapToolBar(newValue) {
    this.state.currentSelectMapToolBar = newValue;
  },
  setCurrentlySelectBase64DataAction(newValue) {
    this.state.BGIMG = newValue;
  },
  clearCurrentlySelectedToolBarAction() {
    this.state.CurrentlySelectedToolBar = {
      Id: '',
      ImgType: '',
      Type: '', //选中的工具栏svg类型
      TypeName: '', //选中的工具栏svg类型名称
      Title: '', //选中的工具栏svg标题
      Color: '', //选中的工具栏svg颜色
      CreateType: '', //选中工具栏的创建方式
      EChartsOption: '', //选中工具栏的图表默认option
      Template: '',
      Default_Attr: {},
    };
  },
  clearCurrentlySelectedMapToolBarAction() {
    this.state.currentSelectMapToolBar = {
      createType: '',
      geometryType: '',
      componentType: '',
      name: '',
      layerStyle: {},
      sourceData: {},
    };
  },
  clearCurrentlySelectBase64DataAction() {
    this.state.BGIMG = {
      ID: 'FirstOneBgImg',
      TYPE: 'default',
      BASE64DATA: '',
    };
  },
};
